Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add styled formatting option to Signal Messenger integration - Bump pysignalclirestapi to 0.3.24 #117148

Merged
merged 14 commits into from
Jun 22, 2024

Conversation

r-xyz
Copy link
Contributor

@r-xyz r-xyz commented May 9, 2024

pysignalclirestapi v0.3.24 enables "text_mode" for the Signal Messenger integration.

Changelog: bbernhard/pysignalclirestapi@0.3.23...0.3.24

Breaking change

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented May 9, 2024

Hey there @bbernhard, mind taking a look at this pull request as it has been labeled with an integration (signal_messenger) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of signal_messenger can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign signal_messenger Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@bbernhard
Copy link
Contributor

Are you sure that those changes are enough? I think for the text_mode parameter to work, there are also changes in the signal integration needed.

Copy link
Contributor

@NECH2004 NECH2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainfest, requirements_all.txt and requirements_test_all.txt are changed. Looks ok.

@r-xyz
Copy link
Contributor Author

r-xyz commented May 9, 2024

@bbernhard thanks for the heads up, I ran the local tests but I could not double check with a real instance.
After a more in depth look, you are right, code should be modified for the additional parameter to be passed.
Will update as soon as I can get to my workstation.

@r-xyz r-xyz marked this pull request as draft May 9, 2024 19:07
@r-xyz
Copy link
Contributor Author

r-xyz commented May 19, 2024

@bbernhard I added the parameter in notify.py.
Could you please have a look if it makes sense? Thank you.

I followed the example of other additional parameters, though I am wondering if it could be moved to the main data structure:
from

action:
  service: notify.NOTIFIER_NAME
  data:
    message: "Test **message**"
    data:
      text_mode: "styled"

to

action:
  service: notify.NOTIFIER_NAME
  data:
    message: "Test **message**"
    text_mode: "styled"

@bbernhard
Copy link
Contributor

Thanks for the PR!

I followed the example of other additional parameters, though I am wondering if it could be moved to the main data structure.

good question. Personally I do not have a preference - both is fine for me. But not sure if the Home Assistant core team has some guidelines for that.

@r-xyz
Copy link
Contributor Author

r-xyz commented Jun 10, 2024

@bbernhard
In order to add text_mode parameter to DATA_SCHEMA , I had to redefine the schema.

Currently the main "breaking" change would be for url-defined attachments:

  • from:
action:
  service: notify.NOTIFIER_NAME
  data:
    message: "Person detected on Front Camera!"
    data:
      verify_ssl: false
      urls:
        - "http://homeassistant.local/api/frigate/notifications/<event-id>/thumbnail.jpg"
  • to
action:
  service: notify.NOTIFIER_NAME
  data:
    message: "Person detected on Front Camera!"
    data:
      urls:
        verify_ssl: false
        urls:
          - "http://homeassistant.local/api/frigate/notifications/<event-id>/thumbnail.jpg"

If that is ok from your side, I will add some additional tests for text_mode and mark for review.
Alternatively, data could be restructured as follows:

  • for filenames:
data:
  attachments:
    filenames:
      -  "/config/www/surveillance_camera.jpg"
  • for urls:
data:
  attachements:
    verify_ssl: false
    urls:
      - "http://homeassistant.local/api/frigate/notifications/<event-id>/thumbnail.jpg"

@bbernhard
Copy link
Contributor

Thanks a lot for the update @r-xyz!

I am not sure if I am qualified to answer that, as I do not know how the Home Assistant core team sees breaking changes. Personally, from the perspective of a simple Home Assistant user, I am not a big fan of breaking changes, as they require me to actively change something to get the existing behavior working again. From the perspective of a maintainer of other open source projects, I am not a big fan either, as breaking changes usually result in quite some follow up issues (e.g "Why doesn't this work anymore?").

But I can see that they are sometimes necessary to clean up technical debt. I know that in the early days of Home Assistant, breaking changes occurred quite often and one had to fix stuff manually after almost every release (at least that's how it felt). Due to shortage of free time however, I am not following the Home Assistant development in detail anymore, so I do not know what their stance on breaking changes is. Mabye someone from the Core team can chime in here.

Although personally I am not in favor of breaking changes, I am totally fine with it in case the Core team is fine with it :)

@r-xyz
Copy link
Contributor Author

r-xyz commented Jun 11, 2024

Hi @bbernhard,
Thanks for the useful feedback. I agree it might be better to avoid breaking changes unless they might be needed in the future.
I found a way to modify DATA_SCHEMA definition so it is compatible with previous one.
I also added a test for styled mode. Please let me know if I shall also duplicate tests with successful attachment of file/urls for text_mode = 'styled'.
After I receive feedback, I will submit a PR for docs and mark both for review by maintainers.
PS: the PR was tested and works correctly as custom component.

@bbernhard
Copy link
Contributor

Many thanks for working around the breaking change - very much appreciated!

From my side the extension looks good! ✔️

Thanks a lot for for working on this - this will make quite some Home Assistant users happy :)

@r-xyz r-xyz changed the title Bump pysignalclirestapi to 0.3.24 Add styled formatting option to Signal Messenger integration - Bump pysignalclirestapi to 0.3.24 Jun 11, 2024
@r-xyz r-xyz marked this pull request as ready for review June 11, 2024 22:49
@r-xyz
Copy link
Contributor Author

r-xyz commented Jun 11, 2024

Added additional tests and docs.
The only currently failing pipeline appear to be unrelated (please check logs).

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Jun 12, 2024
@r-xyz
Copy link
Contributor Author

r-xyz commented Jun 13, 2024

has-tests and new-feature tags were be added automatically since PR was initially opened without.

@r-xyz
Copy link
Contributor Author

r-xyz commented Jun 16, 2024

@frenck Please let me know in case additional changes are needed.

@r-xyz
Copy link
Contributor Author

r-xyz commented Jun 18, 2024

Improved exception handling, codecov is now also fully passed.
It only needs approving review.

@r-xyz r-xyz requested a review from bbernhard June 18, 2024 00:16
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @r-xyz 👋

Thanks for the PR! Left some suggestions to let the schema validation handle all these default and validation magic, removing the need for the get_text_mode method.

../Frenck

homeassistant/components/signal_messenger/notify.py Outdated Show resolved Hide resolved
homeassistant/components/signal_messenger/notify.py Outdated Show resolved Hide resolved
homeassistant/components/signal_messenger/notify.py Outdated Show resolved Hide resolved
homeassistant/components/signal_messenger/notify.py Outdated Show resolved Hide resolved
homeassistant/components/signal_messenger/notify.py Outdated Show resolved Hide resolved
homeassistant/components/signal_messenger/notify.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft June 22, 2024 09:17
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@frenck frenck removed the smash Indicator this PR is close to finish for merging or closing label Jun 22, 2024
@r-xyz r-xyz marked this pull request as ready for review June 22, 2024 15:06
@home-assistant home-assistant bot requested a review from frenck June 22, 2024 15:06
@r-xyz
Copy link
Contributor Author

r-xyz commented Jun 22, 2024

Requested changes were implemented. One test needed to be modified, too, since invalid text_mode attribute now gives error instead of defaulting to "normal" with warning (previous behaviour).

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Jun 22, 2024
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @r-xyz 👍

../Frenck

@frenck frenck merged commit cdc157d into home-assistant:dev Jun 22, 2024
39 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed dependency integration: signal_messenger Quality Scale: No score small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants